define(function(require,exports,module) {
 //    require('./plug/hammer.min');
	// require('./plug/lazyload_echo');
	//require('shop');
    var myPub = require('./public');

    var oHeader = $('.js_header');              	//头部
    var oFooter = $('.js_footer');              	//底部
    var oGoods_showChangeBox = $('.js_goods_showChangeBox');              	//底部

	oHeader.on("touchmove",function(e) {e.preventDefault()});
    oFooter.on("touchmove",function(e) {e.preventDefault()});
    //oSearchBox.on("touchmove",function(e) {e.preventDefault()});

    //产品懒加载  异步加载 调用这个
    myPub.lazLoadingImgEcho()

    var goodsList = [];
	module.exports = {
        init:function(data,name){
        	goodsList = data;
        }
    };

	//显示更多
	var  oMoreBtn = $('.js_moreBtn'); 			//加载更多按钮
	$('#more').show();

	var limit = 20;
	var pageNo = 1;
	var loadTime = null;
	var loadGoHeight = oGoods_showChangeBox.find('li').height();

	oMoreBtn.hammer().on('tap',function() {

		var begin = pageNo*limit;
		var end = (pageNo+1)*limit;
		if(end>=goodsList.length){
			end = goodsList.length;
		}

		var _this = $(this);
		_this.hide().siblings('.js_loadingBtn').show().find('.icoStyle').addClass('myRotateRefresh');
		var html="";

		for(var i=begin;i<end;i++){
			//console.log(goodsList[i]+"i:"+i);
			html+='<li>'+
					'<a class="" href="/shop/goods/view/'+goodsList[i].goodsSn+'">'+
					    '<figure>'+
					        '<img class="js_lazyImg" data-echo="'+myPub.httpImageUrl + goodsList[i].showImage + '" src="/static_v3/image/loadImg.jpg">'+
//					        '<img class="js_lazyImg" data-echo="'+myPub.httpImageUrl + goodsList[i].showImage + '">'+
					        '<i class="tip-th" style="display: none;"></i>'+
					    '</figure>'+
					    '<aside class="priceArea ">'+
					    	'<div class="priceArea_name">'+
					    		'<h4>'+goodsList[i].name+'</h4>'+
					    		'<p class="smallFont_tip">'+goodsList[i].title+'</p>'+
					    	'</div>'+
					    	'<div class="priceArea_price">'+
				            	'<p class="HBox BoxCenter priceAreaBox">'+
				                        '<i>￥</i>'+
				                        '<span class="goodsPrice">'+goodsList[i].salePrice+'</span>'+
				                        '<span class="goodsWeight Bflex1">/'+goodsList[i].productName+'</span>'+
				                '</p>'+
			            	'</div>'+
					    '</aside>'+
					'</a>'+
					'<p class="addCar js_addCar" pId="'+goodsList[i].productId+'"><em class="icon-shopcar_small"></em></p>'+
				'</li>';
		}

		//单个li
		setTimeout(function () {
			pageNo++;
			oGoods_showChangeBox.find('ul').append(html);

			_this.show().siblings('.js_loadingBtn').hide().find('.icoStyle').removeClass('myRotateRefresh');

			//产品懒加载  异步加载 调用这个
    		myPub.lazLoadingImgEcho()

    		myPub.SetImgHeight(oGoods_showChangeBox)

    		$(window).scrollTop() + loadGoHeight

    		if((end-begin)<limit){
				$('#noMore').show();
				$('#more').hide();
			}

		},300)

		myPub.HamstopPropaga()
	})



});